package com.hey.amqpdemo.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

/**
 * @ClassName ConfirmCallBackListener
 * @Author hey
 * @Date 2019/3/25 10:47
 **/
@Slf4j
@Service
public class ConfirmCallBackListener implements RabbitTemplate.ConfirmCallback {
    @Override
    public void confirm(CorrelationData correlationData, boolean b, String s) {
        if(b){
            log.info("确认成功，消息ID："+correlationData.getId());
            log.info("消息为："+correlationData.getReturnedMessage());
        }else {
            log.error("确认失败，消息ID："+correlationData.getId());
            log.error("原因为："+s);
        }
    }
}
